function negLL = ptm2(params,wdata)
% params(1): lottery weighting for buyer
% params(2): decisiveness
% params(3): response bias for buyer
% params(1): lottery weighting for seller
% params(4): response bias for seller
% params(5): fixed utility for buyer
% params(6): fixed utility for seller

priceutil = wdata.Price;
lotteryutil = (wdata.Role==1).* (0.5.*params(1).*wdata.Lottery) + ...
              (wdata.Role==2).* (0.5.*params(1).*wdata.Lottery);
pending = (wdata.Role==1).*((params(3)>=0).*((1-params(3))./(1+exp(-params(2)*(lotteryutil-priceutil) + params(5)))+ params(3)) + (1-(params(3)>=0)).*(1+params(3))./(1+exp(-params(2)*(lotteryutil-priceutil) + params(5)))) + ...
          (wdata.Role==2).*((params(4)>=0).*((1-params(4))./(1+exp(-params(2)*(lotteryutil-priceutil) + params(6)))+ params(4)) + (1-(params(4)>=0)).*(1+params(4))./(1+exp(-params(2)*(lotteryutil-priceutil) + params(6)))) ;
% pending(pending==0) = eps; 
negLL = - sum( wdata.Ending.*log(pending) + (1-wdata.Ending).*log(1-pending) );

end